package com.learn.mapstruct.inheritConfiguration;

import com.learn.mapstruct.inheritConfiguration.model.InheritConfigurationEntity;
import com.learn.mapstruct.inheritConfiguration.model.InheritConfigurationEntity2;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

@Mapper
public interface InheritConfigurationMapper {

    @Named("to")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "name2", source = "name")
    InheritConfigurationEntity2 to(InheritConfigurationEntity entity);

    @Named("to2")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "name2", source = "name", defaultValue = "name2Value", conditionExpression = "java(\"demo\".equalsIgnoreCase(entity.getName()))")
    InheritConfigurationEntity2 to2(InheritConfigurationEntity entity);

    @InheritConfiguration(name = "to2")
    InheritConfigurationEntity2 to3(InheritConfigurationEntity entity);


}
